# -*- coding: utf-8 -*-

import time

class UnixTime:

    def timestamp_datetime(self, value):
        if len(value) > 10:
            value = value[0:10]

        format = '%Y-%m-%d %H:%M:%S'
        value = time.localtime(int(value))
        dt = time.strftime(format, value)

        return dt

    def datetime_timestamp(self, dt):
        s = time.mktime(time.strptime(dt, '%Y-%m-%d %H:%M:%S'))

        return int(s)

if __name__ == '__main__':
    unix = UnixTime()
    d = unix.datetime_timestamp('2016-4-19 10:46:00')
    print d

    s = unix.timestamp_datetime('1474646400')
    print s